﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using UserDefineForm.exception;
using UserDefineForm.formcomponent;
using UserDefineForm.control.propertymapping;

namespace UserDefineForm.control
{
    class DesignableRadioButton:DesignableControlBase
    {
        override protected bool IsResizable
        {
            get { return false; }

        }

        override public String Value
        {
            set
            {
                RadioButton radioBtn = (RadioButton)this.control;
                bool boolValue;
                if (!bool.TryParse(value,out boolValue))
                {
                    throw new InvalidValueException(InvalidValueException.INVALID_BOOLEAN + value);
                }
                radioBtn.Checked = boolValue;
            }

            get
            {
                RadioButton radioBtn = (RadioButton)this.control;
                return radioBtn.Checked.ToString();
            }
        }


        public DesignableRadioButton(DesignPanel designPanel, PropertiesPanelv2 propPnl)
            : base(designPanel, propPnl)
        {
            this.control = new RadioButton();
            this.mainPnl.Controls.Add(this.control);
            this.mappingObject = new RadioButtonMappingObject();

            control.AutoSize = true;
            this.Size = new Size(22, 13);
           // setUnResizable();
            //checkBox.Size= new Size(checkBox.Size.Width,
        }

        public override ControlType getType()
        {
            return ControlType.RadioButton;
        }
    }
}
